package com.example.community.list;

import com.example.community.dao.PaytypeDao;
import com.example.community.model.Paytype;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(urlPatterns = "/payTypeListServlet")
public class PayTypeListServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Integer ys = null;
        if (req.getParameter("ys")==null){
            ys = 1 ; //当前页数
        }else {
            ys = Integer.parseInt(req.getParameter("ys"));
        }
        int shuju = 8; //每页显示数据个数
        PaytypeDao paytypeDao = new PaytypeDao();
        List<Paytype> paytypes = paytypeDao.fandLimit(ys, shuju);
        Integer totalPageNum = paytypeDao.selectLimitCount(shuju);
        req.setAttribute("paytypes",paytypes);
        req.setAttribute("totalPageNum",totalPageNum);
        req.setAttribute("ys",ys);
        req.getRequestDispatcher("/WEB-INF/payManager/paytypeList.jsp").forward(req,resp);
    }
}
